package com.voxel.sense.infomsg.module.map.monitor;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.example.com.common.app.BaseActivity;
import com.voxel.sense.infomsg.R;
import com.voxel.sense.infomsg.module.map.monitor.baseInfo.MonitorMapActivity;
import com.voxel.sense.infomsg.module.map.monitor.traceRecord.TraceActivity;
import com.voxel.sense.infomsg.module.trace.staff.StaffClockInListActivity;
import com.voxel.sense.infomsg.view.titlebar.TextTitleBar;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import cyy.example.com.facotry.constants.IntentConstants;
import cyy.example.com.facotry.model.api.response.FirmLocationEntity;

public class MonitorInfoActivity extends BaseActivity {
    @BindView(R.id.ll_monitor_info)
    LinearLayout ll_monitor_info;
    @BindView(R.id.ll_record_trace)
    LinearLayout ll_record_trace;
    @BindView(R.id.ll_history_trace)
    LinearLayout ll_history_trace;
    @BindView(R.id.titlebar)
    TextTitleBar titlebar;

    private double mLatitude;
    private double mLongitude;
    private List<FirmLocationEntity> entity;


    public static void show(Context context, List<FirmLocationEntity> entity,
                            double latitude, double longitude) {
        Intent intent = new Intent(context, MonitorInfoActivity.class);
        Bundle bundle = new Bundle();
        if (entity != null) {
            bundle.putSerializable(IntentConstants.OBJECT_TYPE, (ArrayList) entity);
        }

        bundle.putDouble(IntentConstants.LATITUDE, latitude);
        bundle.putDouble(IntentConstants.LONGITUDE, longitude);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    @Override
    protected int getContentLayoutId() {
        return R.layout.activity_monitor_info;
    }

    @Override
    protected boolean initArgs(Bundle bundle) {
        if (bundle != null) {
            entity = (List<FirmLocationEntity>) bundle.getSerializable(IntentConstants.OBJECT_TYPE);
            mLatitude = bundle.getDouble(IntentConstants.LATITUDE, -1);
            mLongitude = bundle.getDouble(IntentConstants.LONGITUDE, -1);
        }
        return super.initArgs(bundle);
    }

    @Override
    protected void initData() {
        super.initData();
        titlebar.setTitleText("数据");
    }

    @OnClick({R.id.ll_monitor_info, R.id.ll_history_trace, R.id.ll_record_trace})
    void onClickEvent(View view) {
        switch (view.getId()) {
            case R.id.ll_monitor_info:
                MonitorMapActivity.show(this, entity, mLatitude, mLongitude);
                break;
            case R.id.ll_history_trace:
                StaffClockInListActivity.show(this);
                break;
            case R.id.ll_record_trace:
                TraceActivity.show(this, mLatitude, mLongitude);
                break;
        }
    }
}
